package com.chdwmp.product.utils;

import java.util.Calendar;

public class SequenceUtils {

    public static String getSequence() {
        StringBuffer buffer = new StringBuffer();

        Calendar calendar = Calendar.getInstance();
        String year = String.valueOf(calendar.get(Calendar.YEAR)).substring(2, 4);//获取年份
        String month = calendar.get(Calendar.MONTH) + 1 < 10 ? "0" + (calendar.get(Calendar.MONTH) + 1)
                : String.valueOf(calendar.get(Calendar.MONTH) + 1);//获取月份
        String day = calendar.get(Calendar.DATE) < 10 ? "0" + calendar.get(Calendar.DATE)
                : String.valueOf(calendar.get(Calendar.DATE));//获取日
        String hour = calendar.get(Calendar.HOUR) < 10 ? "0" + calendar.get(Calendar.HOUR)
                : String.valueOf(calendar.get(Calendar.HOUR));//小时
        String minute = calendar.get(Calendar.MINUTE) < 10 ? "0" + calendar.get(Calendar.MINUTE)
                : String.valueOf(calendar.get(Calendar.MINUTE));//分
        String second = calendar.get(Calendar.SECOND) < 10 ? "0" + calendar.get(Calendar.SECOND)
                : String.valueOf(calendar.get(Calendar.SECOND));//秒

        buffer.append(year).append(month).append(day).append(hour)
                .append(minute).append(second).append((int) ((Math.random() * 9 + 1) * 100000));

        return buffer.toString();
    }
}
